class MyThread1 extends Thread{
    int ticket=20;
    @Override
    public void run(){
        while (this.ticket>0){
            System.out.println(Thread.currentThread().getName()+"在卖票,"+"票号为"+this.ticket--);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
        System.out.println(Thread.currentThread().getName()+"的票卖完了");
    }
}
public class Demo09 {
    public static void main(String[] args) {
        MyThread1 t1=new MyThread1();
        MyThread1 t2=new MyThread1();
        MyThread1 t3=new MyThread1();
        t1.setName("窗口1");
        t2.setName("窗口2");
        t3.setName("窗口3");
        t1.start();
        t2.start();
        t3.start();
    }
}
